// pages/address/address.js
import {reqAddress} from '../../api/address'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    addressList:[]
    
  },

  navigateToAddressEdit:function() {
    wx.navigateTo({
      url: '/pages/addressedit/addressedit',
    })
  },

  navigateToAddressAdd:function() {
    wx.navigateTo({
      url: '/pages/addressadd/addressadd',
    })
  },

  onShow(){
    this.listaddress()
  },

  async listaddress(){
    const res = await reqAddress()
    this.setData({
      addressList:res.data
    })
  },

  AddressEdit: function(e) {
    const id = e.currentTarget.dataset.id; // 获取传递的 id
    // console.log(e.currentTarget.dataset);
    // console.log('Address ID:', id);
    // 这里可以进行编辑地址的逻辑，例如导航到编辑页面并传递 id
    wx.navigateTo({
      url: `/pages/addressedit/addressedit?id=${id}`
    });
  }
})